home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 24 / AACD 24.iso / AACD / Graphics / vcdimager / source / differ2.txt < prev    next >
Text File  |  2001-07-02  |  3KB  |  105 lines

  1. diff -Pc3prb ram:old/rint.c ./rint.c
  2. *** ram:old/rint.c    Thu Jan  1 00:00:00 1970
  3. --- ./rint.c    Mon Jul  2 19:15:43 2001
  4. ***************
  5. *** 0 ****
  6. --- 1,98 ----
  7. + #include <math.h>
  8. + #if defined(vax)||defined(tahoe)
  9. + // Deal with different ways to concatenate in cpp
  10. + #  ifdef __STDC__
  11. + #    define    cat3(a,b,c) a ## b ## c
  12. + #  else
  13. + #    define    cat3(a,b,c) a/**/b/**/c
  14. + #  endif
  15. + // Deal with vax/tahoe byte order issues
  16. + #  ifdef vax
  17. + #    define    cat3t(a,b,c) cat3(a,b,c)
  18. + #  else
  19. + #    define    cat3t(a,b,c) cat3(a,c,b)
  20. + #  endif
  21. + #  define vccast(name) (*(const double *)(cat3(name,,x)))
  22. + #  define vc(name, value, x1,x2,x3,x4, bexp, xval) \
  23. +     const static long cat3(name,,x)[] = {cat3t(0x,x1,x2), cat3t(0x,x3,x4)};
  24. + #  define ic(name, value, bexp, xval) ;
  25. + #else    //  vax or tahoe
  26. +    // Hooray, we have an IEEE machine
  27. + #  undef vccast
  28. + #  define vc(name, value, x1,x2,x3,x4, bexp, xval) ;
  29. + #  define ic(name, value, bexp, xval) \
  30. +     const static double name = value;
  31. + #endif    /* defined(vax)||defined(tahoe) */
  32. + vc(L, 4503599627370496.0E0 ,0000,5c00,0000,0000, 55, 1.0) /* 2**55 */
  33. + ic(L, 4503599627370496.0E0, 52, 1.0)              /* 2**52 */
  34. + #ifdef vccast
  35. + #define    L    vccast(L)
  36. + #endif
  37. + #if defined(vax)||defined(tahoe)      /* VAX D format */
  38. + #include <errno.h>
  39. +     static const unsigned short msign=0x7fff , mexp =0x7f80 ;
  40. +     static const short  prep1=57, gap=7, bias=129           ;
  41. +     static const double novf=1.7E38, nunf=3.0E-39, zero=0.0 ;
  42. + #else    /* defined(vax)||defined(tahoe) */
  43. +     static const unsigned short msign=0x7fff, mexp =0x7ff0  ;
  44. +     static const short prep1=54, gap=4, bias=1023           ;
  45. +     static const double novf=1.7E308, nunf=3.0E-308,zero=0.0;
  46. + #endif    /* defined(vax)||defined(tahoe) */
  47. + double copysign(double x,double y)
  48. + {
  49. + #ifdef national
  50. +         unsigned short  *px=(unsigned short *) &x+3,
  51. +                         *py=(unsigned short *) &y+3;
  52. + #else    /* national */
  53. +         unsigned short  *px=(unsigned short *) &x,
  54. +                         *py=(unsigned short *) &y;
  55. + #endif    /* national */
  56. + #if defined(vax)||defined(tahoe)
  57. +         if ( (*px & mexp) == 0 ) return(x);
  58. + #endif    /* defined(vax)||defined(tahoe) */
  59. +         *px = ( *px & msign ) | ( *py & ~msign );
  60. +         return(x);
  61. + }
  62. + double rint(double x)
  63. + {
  64. +     double s,t;
  65. +     const double one = 1.0;
  66. +     if (x != x)                /* NaN */
  67. +         return (x);
  68. +     if (copysign(x,one) >= L)        /* already an integer */
  69. +         return (x);
  70. +     s = copysign(L,x);
  71. +     t = x + s;                /* x+s rounded to integer */
  72. +     return (t - s);
  73. + }
  74.